package weeny.demo;

import java.awt.Dimension;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;

import prefuse.Constants;
import prefuse.util.ui.UILib;
import prefuse.visual.EdgeItem;
import prefuse.visual.NodeItem;
import prefuse.visual.VisualItem;
import weeny.pre.display.MarkerDisplay;
import weeny.pre.util.IntColor;
import weeny.pre.util.Pre;

public class MarkerDisplayDemo implements Constants {
	
	public static void main(String[] args) {
		UILib.setPlatformLookAndFeel();
		final MarkerDisplay dsp = new MarkerDisplay();
		dsp.setSize(new Dimension(900, 750));
		
		//samples about how to draw five different types of things
		dsp.drawString(
				"Display Demo", new Point2D.Double(400,400), IntColor.BLUE, 10);
		VisualItem vi = dsp.drawLine(
				new Line2D.Double(400,100,229,400), IntColor.CATEGORY_4[2], 10);
		vi.setStroke(Pre.roundStroke(10));
		dsp.drawShape(
				new Point2D.Double(300,200), 10, SHAPE_CROSS, IntColor.BROWN);
		vi = dsp.drawPolyline(
				new float[]{50,50,200,100,100,200,300,400}, IntColor.PINK, 10);
		vi.setStroke(Pre.roundStroke(10));
		dsp.fillPolygon(
				new float[]{932,643,623,523,456,654}, IntColor.YELLOW);
		vi = dsp.drawCurve(
				new float[]{700,300,300,400,488,119,680,60}, IntColor.RED, 15);
		vi.setStroke(Pre.roundStroke(10));
		//the return item can be further edited, for example
		EdgeItem arrow = dsp.drawArrow(
				new Line2D.Double(100, 400, 200,300), IntColor.GREEN, 10);
		arrow.getSourceItem().setX(10);
		
		//drawing graph things
		NodeItem a = dsp.drawGraphNode(
				new Point2D.Double(200,500), 2, SHAPE_ELLIPSE, IntColor.BLUE);
		NodeItem b = dsp.drawGraphNode(
				new Point2D.Double(250,550), 2, SHAPE_ELLIPSE, IntColor.BLUE);
		NodeItem c = dsp.drawGraphNode(
				new Point2D.Double(300,500), 2, SHAPE_ELLIPSE, IntColor.BLUE);
		dsp.drawGraphEdge(a, b, IntColor.ORIANGE, 5);
		dsp.drawGraphEdge(b, c, IntColor.ORIANGE, 5);
		
		//show control tabs
		dsp.showIODisplayTab();
		dsp.showItemControlTabInTree();
		dsp.showVisualMarkerTab();
		
		dsp.showFrame("Marker Demo");
	}
}